// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import Vuex from 'vuex'
import VueRouter from 'vue-router'
import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css';

import StoreConfig from './store/store'
import util from './libs/util'
import RouterConfig from './router'
import App from './App'

Vue.use(Vuex)
Vue.use(VueRouter)
Vue.use(ElementUI)

// 路由配置
const router = new VueRouter({
    // mode: 'history',
    // history: true,
    saveScrollPosition: true,
    transitionOnLoad: true,
    routes: RouterConfig
})

// router.beforeEach((to, from, next) => {
//     // console.log(to,from)
//     // 判断在搜索路由中退回首页清除搜索关键词
//     if(to.name=='Home'){
//         util.setlocalStorage('keyword','')
//     }
//
//     if(to.name=='Content'){
//         // console.log(window.scrollY);
//         // util.setlocalStorage('homeScrollPosition',{y:window.scrollY})
//         // window.scrollTo(0, 0)
//     }else{
//         // window.scrollTo(0, util.getlocalStorage('homeScrollPosition').y)
//     }
//     next();
// });
//
// router.afterEach((to, from, next) => {
//
// });

// vuex
const store = new Vuex.Store(StoreConfig)

Vue.config.productionTip = false

/* eslint-disable no-new */
const app = new Vue({
    el: '#app',
    router,
    store: store,
    template: '<App/>',
    components: {
        App
    }
})
